package com.jimmy.medical.repository;

import com.jimmy.medical.entity.Order;
import com.jimmy.medical.entity.UploadFile;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrderRepository extends JpaSpecificationExecutor<Order>, PagingAndSortingRepository<Order, Long> {

    Order findFirstByPayFlowNo(String payFlowNo);

    @Query(value = "select f from OrderFile ofile left join ofile.order o left join ofile.file f where o.id=?1 and f.fileType=?2")
    List<UploadFile> findNeedFile(Long orderId, Integer fileType);
}
